﻿
//自动义双击方法
function CustomDbClick() {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData("ID");
    //var vid = record.getData("WorkFlowInsId");
    if (vid != "") {
        window.parent.$("#tabs").tabs('close', '查看交付申请单--公开课');
        var pagetitle = "查看交付申请单--公开课";
        parent.addTabs(pagetitle, '../Crm/Deliver/AddDeliverMajor.aspx?r=' + Math.random() + '&view=check&flag=1&entity=' + const_EditEntity + '&id=' + vid + '&title=' + encodeURI(pagetitle));
        parent.NeedRefreshPage = this;
    }
}
//自定义新增方法
//var fnCustomAdd = function () {
//    window.parent.$("#tabs").tabs('close', '交付申请单--公开课');
//    var pagetitle = "交付申请单--公开课";
//    parent.addTabs(pagetitle, '../Crm/Deliver/AddDeliverMajor.aspx?r=' + Math.random() + '&flag=0&entity=' + const_EditEntity + '&title=' + encodeURI(pagetitle));
//    parent.NeedRefreshPage = this;
//}
//自定义新增方法
var fnCustomAdd = function () {
    window.parent.$("#tabs").tabs('close', '起草公开课申请单');
    var pagetitle = "起草公开课申请单";
    parent.addTabs(pagetitle, '../Crm/BasePages/StartWorkflow.aspx?title=' + encodeURI(pagetitle) + '&WorktaskId=09b46be8-d33f-46bd-99da-21eb2340bddb&WorkflowId=dbe29f15-9971-4511-ad5a-c6e53ceb214a');
    parent.NeedRefreshPage = this;
}
//自定义修改方法
var fnCustomEdit = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData("ID");
    //var vid = record.getData("WorkFlowInsId");
    var wtid = record.getData("WorkTaskId");
    var wfid = record.getData("WorkFlowId");
    if (vid != "") {
        window.parent.$("#tabs").tabs('close', '修改交付申请单--公开课');
        var pagetitle = "修改交付申请单--公开课";
        parent.addTabs(pagetitle, '../Crm/Deliver/AddDeliverMajor.aspx?r=' + Math.random() + '&flag=2&view=c&entity=' + const_EditEntity + '&wtid=' + wtid + '&wfid=' + wfid + '&id=' + vid + '&title=' + encodeURI(pagetitle));
        parent.NeedRefreshPage = this;
    }
}
//自定义删除方法
var fnCustomDeleteData = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    var record = myDataTable.getRecord(recordID);
    var vid = record.getData(const_entityID);
    if (vid != "") {
        var SaveUrl = "../../Extend/AjaxData/CustomOperating.aspx?r=" + Math.random() + "&action=delete&entity=CrmDeliverMajor&json=&id=" + vid;
        YAHOO.util.Connect.asyncRequest('POST', SaveUrl, {
            success: function (res) {
                try {
                    var str = res.responseText;
                    if (str == "1") {
                        YAHOO.example.container.dialog3.hide();
                        alert("删除成功!");
                        RefreshData();
                        return;
                    } else {
                        alert(str);
                    }
                }
                catch (e) {
                }
                finally {
                }
            },
            failure: function (error) {
                alert("数据错误：" + error.statusText);
            }
        }, null);
    }
}
//格式化确认列
var formatIsSure = function (elCell, oRecord, oColumn, sData) {
    if (sData == "0") {
        elCell.innerHTML = "未确认";
    } else {
        elCell.innerHTML = "已确认";
    }
}
//格式化确认时间
var formatSureTime = function (elCell, oRecord, oColumn, sData) {
    if (sData == "0001-01-01 " || sData == "1900-01-01 " || sData == null) {
        elCell.innerHTML = "";
    } else {
        elCell.innerHTML = sData;
    }
}
//格式化是否完款
var formatExp3 = function (elCell, oRecord, oColumn, sData) {
    if (sData == "0") {
        elCell.innerHTML = "否";
    } else if (sData == "1") {
        elCell.innerHTML = "是";
    } else {
        elCell.innerHTML = "";
    }
}
//变更
var fnModifyM = function () {
    var recordID = myDataTable.getSelectedRows()[0];
    record = myDataTable.getRecord(recordID);
    var vid = record.getData("ID");
    //var vid = record.getData("WorkFlowInsId");
    var wtid = record.getData("WorkTaskId");
    var wfid = record.getData("WorkFlowId");
    var state = record.getData("DeliverStateName");
    if (state == "交付中") {
        if (vid != "") {
            window.parent.$("#tabs").tabs('close', '变更交付申请单--公开课');
            var pagetitle = "变更交付申请单--公开课";
            parent.addTabs(pagetitle, '../Crm/Deliver/AddDeliverMajor.aspx?r=' + Math.random() + '&flag=2&view=m&entity=' + const_EditEntity + '&wtid=' + wtid + '&wfid=' + wfid + '&id=' + vid + '&title=' + encodeURI(pagetitle));
            parent.NeedRefreshPage = this;
        }
    } else {
        alert("请选择【交付中】的公开课交付单!");
    }
}